class Bicycle {
  int cadence;
  int _speed = 0;
  int gear;
  int get speed => _speed;
  Bicycle(this.cadence, this.gear);

  @override
  String toString() => 'Bicycle: $speed mph';

  void applyBrake(int decrement) {
    _speed -= decrement;
  }

  void speedUp(int increment) {
    _speed += increment;
  }
}

class People {
  static String name = 'abcd';
  void show() {
    // 实例化后的类也可以访问该静态变量 不能使用this
    // People().show(), 不能People().name
    print(name);
  }

  // 静态方法可以通过外部直接访问 People.printName();
  static void printName() {
    print(name);
  }
}

void main() {
  var bike = new Bicycle(2, 1);
  print(bike);
  bike.speedUp(2);
  print(bike);
  // 静态变量可以通过外部直接访问,不需要将类实例化
  print(People.name);
}
